<?php
session_start();
require_once 'classes/Pizzeria.class.php';
require_once 'classes/Pizza.class.php';
require_once 'classes/User.class.php';
require_once 'classes/Ingredient.class.php';

	function affiche(){
		$parametres=null;
		if(isset($_SESSION['user'])){
			if($_SESSION['user']!=null){
				if(isset($_SESSION['isadmin'])&&$_SESSION['isadmin']=='yes'){
					$infoPizzeria = array ( 'nom'  => 'monzPizza','onglets' => array('pizzas','menus','boissons','commandes'));
					$parametres=array("role" => "admin");
				}
				else{
					$infoPizzeria = array ( 'nom'  => 'monzPizza','onglets' => array('pizzas','menus','boissons','compte'));
					$parametres=array("role" => "user");
				}
			}
		}
		else{
			$infoPizzeria = array ( 'nom'  => 'monzPizza','onglets' => array('pizzas','menus','boissons','connection'));
			$parametres=array("role" => "ext");
		}
		$maPizzeria=new Pizzeria($infoPizzeria);
		$maPizzeria->remplirTableau(Pizza::getAll());
		$xp = new XsltProcessor();
		$xsl = new DomDocument;
		$xsl->load('mainVue.xsl');
		// import the XSL styelsheet into the XSLT process
		$xp->importStylesheet($xsl);
		$xml_doc = new DomDocument;
		$xml_doc->loadXML($maPizzeria->getXML());
		$xp->setParameter('', 'role',$parametres['role']);
		if ($html = $xp->transformToXML($xml_doc)) {
		echo $html;
		} else {
			trigger_error('XSL transformation failed.', E_USER_ERROR);
		}
	}
	affiche();